<?php

	$menuSet = new AdminMenuSet("global", "global_menu");
	array_push($menuSet->menuItems, new AdminMenuItem("menu_admins", "link_admins", null, array("AdminsPage")));
	//array_push($menuSet->menuItems, new AdminMenuItem("menu_sitegroups", "link_sitegroups", null, array("SitegroupsPage")));
	if(MANAGE_SITES_ENABLED)
		array_push($menuSet->menuItems, new AdminMenuItem("menu_sites", "link_manage_sites", null, array("ExtendedsitesPage")));
	array_push($menuSet->menuItems, new AdminMenuItem("menu_files", "link_manage_files", null, array("FilesPage")));
	if(FTP_MANAGEMENT_ENABLED)
		array_push($menuSet->menuItems, new AdminMenuItem("menu_ftp", "link_ftp", null, array("FtpPage")));
	if(UserHandler::isRoot())
		array_push($menuSet->menuItems, new AdminMenuItem("menu_root", "link_root", null, array("KibicrootopersPage", "MigrationPage", "MemcachedPage", "ThreadsPage")));
	AdminMenuSet::addMenuSet($menuSet);

	$menuSet = new AdminMenuSet("siteglobal", "siteglobal_menu", array("MenuSetExtraTemplateFunctions", "siteglobalMenuTemplateAdditions"), array("MenuSetExtraTemplateFunctions", "siteglobalMenuShouldAppear"));
	array_push($menuSet->menuItems, new AdminMenuItem("menu_languages", "link_languages", null, array("LanguagesPage")));
	// array_push($menuSet->menuItems, new AdminMenuItem("menu_tags", "link_tags", null, array("TagsPage")));
	AdminMenuSet::addMenuSet($menuSet);

	if (CLIPBOARD_ENABLED) {
		$menuSet = new AdminMenuSet("clipboard", "clipboard_menu");
		array_push($menuSet->menuItems, new AdminMenuItem("menu_clipboard_copy", "link_clipboard_copy", null, null, null));
		array_push($menuSet->menuItems, new AdminMenuItem("menu_clipboard_cut", "link_clipboard_cut", null, null, null));
		array_push($menuSet->menuItems, new AdminMenuItem("menu_clipboard_paste", "link_clipboard_paste", null, null, null));
		array_push($menuSet->menuItems, new AdminMenuItem("menu_clipboard_page", "link_clipboard", null, array("ClipboardPage")));
		AdminMenuSet::addMenuSet($menuSet);
	}

	$menuSet = new AdminMenuSet("sitelocale", "sitelocale_menu", array("MenuSetExtraTemplateFunctions", "sitelocaleMenuTemplateAdditions"), array("MenuSetExtraTemplateFunctions", "sitelocaleMenuShouldAppear"));
	array_push($menuSet->menuItems, new AdminMenuItem("menu_sitetexts", "link_sitetexts", null, array("SitetextsPage")));
	array_push($menuSet->menuItems, new AdminMenuItem("menu_articles", "link_articles", array("articletype"=>ARTICLE_TYPE_NORMAL), array("ArticlesPage", "FolderedarticlesPage", "EditarticlePage")));
	array_push($menuSet->menuItems, new AdminMenuItem("menu_news", "link_news", array("articletype"=>ARTICLE_TYPE_NEWS), array("NewsPage", "EditnewsPage")));
	array_push($menuSet->menuItems, new AdminMenuItem("menu_galeries", "link_galeries", null, array("GaleriesPage", "GalerycontentPage")));
	array_push($menuSet->menuItems, new AdminMenuItem("menu_menus", "link_menus", null, array("MenusPage")));
	//array_push($menuSet->menuItems, new AdminMenuItem("menu_bannertexts", "link_bannertexts", null, array("BannertextsPage")));
	//array_push($menuSet->menuItems, new AdminMenuItem("menu_questionnaires", "link_questionnaires", null, array("QuestionnairesPage", "EditquestionnairePage", "EditquestionsPage")));
	//array_push($menuSet->menuItems, new AdminMenuItem("menu_forumtopics", "link_forumtopics", null, array("ForumtopicsPage")));
	array_push($menuSet->menuItems, new AdminMenuItem("menu_boxcontents", "link_boxcontents", array("articletype"=>ARTICLE_TYPE_BOXCONTENT), array("BoxcontentsPage", "EditboxcontentPage")));
	array_push($menuSet->menuItems, new AdminMenuItem("menu_boxes", "boxes", null, array("BoxesPage", "BoxtabsPage")));
	array_push($menuSet->menuItems, new AdminMenuItem("menu_tournamenttypes", "link_tournamenttype", null, array("TournamenttypesPage")));
	array_push($menuSet->menuItems, new AdminMenuItem("menu_tournaments", "link_tournament", null, array("TournamentsPage", "TournamentarticlesPage", "TournamentregistrationsPage")));
	AdminMenuSet::addMenuSet($menuSet);
	
// ------ html-be "rajzoláshoz" regisztrálható függvények

	class MenuSetExtraTemplateFunctions {
		
		/**
		 * Eldönti h meg kell-e jelennie a site nyelvfüggő cucciat editáló menü-halmaznak.
		 * Ez egyszerű: ha a site-nak nincs egy árva nyelve sem még, akkor nem!
		 *
		 */
		public static function sitelocaleMenuShouldAppear()
		{
			$langcodes = SiteHandler::getLanguageCodesOfSite(SiteHandler::getCurrentSiteId());
			$shouldAppear = (empty($langcodes) == false);
			return $shouldAppear;
		}

		/**
		 * Eldönti h meg kell-e jelennie a site cuccait editáló menü-halmaznak.
		 * Ez egyszerű: ha egyetlen site sincs amihez a user csatlakozhat, akkor nem
		 *
		 */
		public static function siteglobalMenuShouldAppear()
		{
			$sites = SiteHandler::getSites();
			$availableSites = UserHandler::filterSiteAssociativeArrayDueToPermissions($sites);
			return (count($availableSites) > 0);
		}
		
		/**
		 * A locale menu kirajzolásakor ez a függvény lefut a sablonjára - feladata hogy berakja a nyelvválasztó
		 * cuccait.
		 *
		 * @param HTML_Template_IT $tpl
		 */
		public static function sitelocaleMenuTemplateAdditions($tpl)
		{
			$currSiteId = SiteHandler::getCurrentSiteId();
			if(!is_null($currSiteId))
				$tpl->setVariable('siteName', " ('".SiteHandler::getSite($currSiteId)->name."')");
			else
				$tpl->setVariable('siteName', "");
			
			$langs = AdminBase::getEditLanguages();
			$lang = AdminBase::getCurrentEditlang();
			$deflang = AdminBase::getDefaultEditlang();
			foreach ($langs as $langCode => $langobj)
			{
				$tpl->setCurrentBlock('localeselect');
				$tpl->setVariable('LocaleId', $langCode);
				if($deflang == $langCode)
					$tpl->setVariable('LocaleName', $langobj->langName." *");
				else
					$tpl->setVariable('LocaleName', $langobj->langName);
				if ($lang == $langCode) {
					$tpl->setVariable('LocaleSelected', 'selected="selected"');
				}
				$tpl->parseCurrentBlock();
			}
		}

		
		/**
		 * A site menu kirajzolásakor ez a függvény lefut a sablonjára - feladata hogy berakja a site-választó
		 * cuccait.
		 *
		 * @param HTML_Template_IT $tpl
		 */
		public static function siteglobalMenuTemplateAdditions($tpl)
		{
			$siteSelectorOptions = FormUtil::getComboOptionHTMLTagsFromAssociativeArray(UserHandler::filterSiteAssociativeArrayDueToPermissions(SiteHandler::getSitesForComboBox()), SiteHandler::getCurrentSiteId(), false);
			$tpl->setVariable('siteselector_options', $siteSelectorOptions);
			
			$currSiteId = SiteHandler::getCurrentSiteId();
			if(!is_null($currSiteId))
				$tpl->setVariable('siteName', " ('".SiteHandler::getSite($currSiteId)->name."')");
			else
				$tpl->setVariable('siteName', "");
		}
		
	}
	addClass('MenuSetExtraTemplateFunctions', 'adminMenus.php');
		
?>